package com.hibernate.hrm.entity;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import jakarta.persistence.*;
import lombok.Data;
import lombok.ToString;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Entity
@Table(name = "position")
@Data
@ToString(exclude = {"departmentID", "positionRoleID"})
@JsonIdentityInfo(
        generator = ObjectIdGenerators.PropertyGenerator.class,
        property = "positionId"
)
public class Position {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "PositionID")
    private Integer positionId;

    @ManyToOne
    @JoinColumn(name = "departmentID")
    @JsonIgnoreProperties({"subDepartments", "departmentHeadID"})
    private Department departmentID;

    @Column(name = "PositionName", nullable = false)
    private String positionName;

    @Column(name = "PositionCode", nullable = false, unique = true)
    private String positionCode;

    @ManyToOne
    @JoinColumn(name = "PositionRoleID", nullable = false)
    private Role positionRoleID;

    @Column(name = "MaxHeadCount")
    private Integer maxHeadCount;

    @Column(name = "baseSalary", precision = 10, scale = 2)
    private BigDecimal baseSalary;

    @Column(name = "allowance", precision = 10, scale = 2)
    private BigDecimal allowance;

    @Column(name = "annualLeaveDays", precision = 10, scale = 2)
    private BigDecimal annualLeaveDays;

    @Column(name = "status", nullable = false)
    private Boolean status = true;

    @Column(name = "createTime", nullable = false)
    private LocalDateTime createTime;

    @Column(name = "updateTime")
    private LocalDateTime updateTime;
}
